Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript 4.3 support #544

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false
}
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"editor.insertSpaces": false,
"editor.detectIndentation": false
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ In comparison, TSCC will only include a file when it is reachable from _root fil

#### Importing typescript sources in node_modules

In order for typescript sources in node_modules directory to be compiled, you need to explicitly include those files in your `tsconfig.json`. This is a rule imposed by the typescript compiler; it has some special handling for files in node_modules directory, it won't transpile such files unlike usual transitive dependencies (that is, files not explicitly included in `tsconfig.json` via `"files"` or `"includes"` keys, but is referenced via `import` or `///<reference path="..." />` from a file that is included in `tsconfig.json`). In order to have them compiled, you need to explicitly mention those files in node_modules directory. For instance, if you are using a package `my_package` that contains typescript sources, you can add a key `{"includes": ["node_modules/my_package/**/*.ts"]}` to your tsconfig.
In order for typescript sources in node_modules directory to be compiled, you need to explicitly include those files in your `tsconfig.json`. This is a rule imposed by the typescript compiler; it has some special handling for files in node_modules directory, it won't transpile such files unlike usual transitive dependencies (that is, files not explicitly included in `tsconfig.json` via `"files"` or `"include"` keys, but is referenced via `import` or `///<reference path="..." />` from a file that is included in `tsconfig.json`). In order to have them compiled, you need to explicitly mention those files in node_modules directory. For instance, if you are using a package `my_package` that contains typescript sources, you can add a key `{"include": ["node_modules/my_package/**/*.ts"]}` to your tsconfig.

### Things to know

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lerna": "^3.18.4",
"prettier": "^2.2.1",
"ts-jest": "^24.3.0",
"typescript": "~3.9.5"
"typescript": "^4.3.2"
},
"dependencies": {}
}
318 changes: 318 additions & 0 deletions packages/tscc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/tscc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"rimraf": "^3.0.2",
"source-map": "^0.7.3",
"stream-json": "^1.7.1",
"tsickle": "0.39.1",
"tslib": "^2.0.3",
"typescript": "~3.9.5",
"tsickle": "^0.43.0",
"tslib": "^2.3.0",
"typescript": "^4.3.2",
"upath": "^2.0.1",
"vinyl": "^2.2.0",
"vinyl-fs": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/tscc/src/external_module_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import ITsccSpecWithTS from './spec/ITsccSpecWithTS';
import {TsickleHost} from 'tsickle';
import {moduleNameAsIdentifier} from 'tsickle/src/annotator_host';
import {moduleNameAsIdentifier} from 'tsickle/out/src/annotator_host';

export function getExternsForExternalModules(tsccSpec: ITsccSpecWithTS, tsickleHost: TsickleHost): string {
const header = `\n/** Generated by TSCC */`
Expand Down
6 changes: 6 additions & 0 deletions packages/tscc/src/graph/TypescriptDependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export default class TypescriptDependencyGraph {
if (this.visited.has(fileName)) return;
this.visited.add(fileName);
const sf = <SourceFileWithInternalAPIs>this.host.getSourceFile(fileName);

// sometimes the source file returns undefined on certain packages
// such as the @types/grecaptcha package
if (!sf) {
return;
}
/**
* Files imported to the current file are available in `resolvedModules` property.
* See: Microsoft/Typescript/src/compiler/programs.ts `ts.createProgram > processImportedModules`
Expand Down
Loading