- Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
DocsThe issue relates to how you learn TypeScriptThe issue relates to how you learn TypeScript
Description
π Search Terms
"createProgram" "compiler" "compiler api" "js files createProgram" "js compiler api" "js files compiler" "programmatic compiler js"
π Version & Regression Information
Give my project:
my-project/ ββ src/ β ββ index.js ββ tsconfig.json
The following code:
import ts from 'typescript'; let tsConfigFile = ts.findConfigFile( process.cwd(), ts.sys.fileExists, "tsconfig.json" ); const { config } = ts.readConfigFile(tsConfigFile, ts.sys.readFile); const program = ts.createProgram(['src/index.js'], config); program.getSourceFiles().forEach((sf) => { console.log(1, sf.fileName); });
Where tsconfig.json
looks like:
{ "compilerOptions": { "strict": true, "outDir": "./dist-types", "target": "ESNext", "allowSyntheticDefaultImports": true, "moduleResolution": "NodeNext", "module": "NodeNext", "lib": ["ESNext", "DOM"], "declaration": true, "emitDeclarationOnly": true, "allowJs": true, "checkJs": true, "skipLibCheck": true, "verbatimModuleSyntax": true }, "include": [ "src/index.js" ], "exclude": ["node_modules"], }
Outputs:
1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.es5.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.dom.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.webworker.importscripts.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.scripthost.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.decorators.d.ts 1 /Users/au87xu/cem-typescript-issue/node_modules/typescript/lib/lib.decorators.legacy.d.ts
but src/index.js
is missing from the source files. I feel like this did work in the past, or at least should work on regular js files as well.
β― Playground Link
n/a
π» Code
// Your code here
π Actual behavior
ts.createProgram
does not include src/index.js
π Expected behavior
ts.createProgram
does include src/index.js
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
DocsThe issue relates to how you learn TypeScriptThe issue relates to how you learn TypeScript