This repository was archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
This typings #40
Merged
Merged
This typings #40
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6f7441d
Extract createProgram from applyTypes to allow sharing with instrument
zoehneto a1fc415
Initial implementation, checking for implicit this doesn't work corre…
zoehneto f0242e4
Check implicit this with diagnostic
zoehneto ed0f4e1
Fix body detection and improve test coverage
zoehneto 641f3e5
Address review comments
zoehneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import * as ts from 'typescript'; | ||
|
|
||
| export interface ICompilerOptions { | ||
| /** | ||
| * If given, all the file paths in the collected type info will be resolved relative to this directory. | ||
| */ | ||
| rootDir?: string; | ||
|
|
||
| /** | ||
| * Path to your project's tsconfig file | ||
| */ | ||
| tsConfig?: string; | ||
|
|
||
| // You probably never need to touch these two - they are used by the integration tests to setup | ||
| // a virtual file system for TS: | ||
| tsConfigHost?: ts.ParseConfigHost; | ||
| tsCompilerHost?: ts.CompilerHost; | ||
| } | ||
|
|
||
| export function getProgram(options: ICompilerOptions) { | ||
| let program: ts.Program | undefined; | ||
| if (options.tsConfig) { | ||
| const configHost = options.tsConfigHost || ts.sys; | ||
| const { config, error } = ts.readConfigFile(options.tsConfig, configHost.readFile); | ||
| if (error) { | ||
| throw new Error(`Error while reading ${options.tsConfig}: ${error.messageText}`); | ||
| } | ||
|
|
||
| const parsed = ts.parseJsonConfigFileContent(config, configHost, options.rootDir || ''); | ||
| if (parsed.errors.length) { | ||
| const errors = parsed.errors.map((e) => e.messageText).join(', '); | ||
| throw new Error(`Error while parsing ${options.tsConfig}: ${errors}`); | ||
| } | ||
|
|
||
| program = ts.createProgram(parsed.fileNames, parsed.options, options.tsCompilerHost); | ||
| } | ||
| return program; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for adding
src/*.ts? afaiksrc/**/*.tsalso includes any .ts files directly undersrcThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for me (on Arch Linux) it is required or the files directly under
srcare ignored.