-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): fix TS errors that appear when users Go to Source in VSC…
…ode (#142)
- Loading branch information
1 parent
49b4bf7
commit 45d970b
Showing
8 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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,11 @@ | ||
// strip out lib="dom" and types="node" references; these are needed at build time, | ||
// but would pollute the user's TS environment | ||
const fs = require('fs'); | ||
for (const file of process.argv.slice(2)) { | ||
const before = fs.readFileSync(file, 'utf8'); | ||
const after = before.replace(/^ *\/\/\/ *<reference +(lib="dom"|types="node").*?\n/gm, ''); | ||
if (after !== before) { | ||
fs.writeFileSync(file, after, 'utf8'); | ||
console.error('wrote', file); | ||
} | ||
} |
This file contains 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,14 @@ | ||
// strip out `unknown extends RequestInit ? never :` from dist/src/_shims; | ||
// these cause problems when viewing the .ts source files in go to definition | ||
const fs = require('fs'); | ||
for (const file of process.argv.slice(2)) { | ||
const before = fs.readFileSync(file, 'utf8'); | ||
const after = before.replace( | ||
new RegExp('unknown extends (typeof )?\\S+ \\? \\S+ :\\s*'.replace(/\s+/, '\\s+'), 'gm'), | ||
'', | ||
); | ||
if (after !== before) { | ||
fs.writeFileSync(file, after, 'utf8'); | ||
console.error('wrote', file); | ||
} | ||
} |
This file contains 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 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 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 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,11 @@ | ||
{ | ||
// this config is included in the published src directory to prevent TS errors | ||
// from appearing when users go to source, and VSCode opens the source .ts file | ||
// via declaration maps | ||
"include": ["index.ts"], | ||
"compilerOptions": { | ||
"target": "es2015", | ||
"lib": ["DOM"], | ||
"moduleResolution": "node" | ||
} | ||
} |