Skip to content

Commit 6a2eb81

Browse files
committed
allowJS
1 parent 48f9797 commit 6a2eb81

File tree

5 files changed

+96
-5
lines changed

5 files changed

+96
-5
lines changed

dist/main/atom/utils/atom.js

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/atom/utils/atom.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main/atom/utils/atom.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export function isTypescriptFile(filePath: string | undefined): boolean {
1717
}
1818

1919
export function typeScriptScopes(): ReadonlyArray<string> {
20-
return ["source.ts", "source.tsx", "typescript"]
20+
const tsScopes = atom.config.get("atom-typescript.tsSyntaxScopes")
21+
if (atom.config.get("atom-typescript.allowJS")) {
22+
tsScopes.push(...atom.config.get("atom-typescript.jsSyntaxScopes"))
23+
}
24+
return tsScopes
2125
}
2226

2327
export function isTypescriptEditorWithPath(editor: Atom.TextEditor) {
@@ -30,7 +34,11 @@ export function isTypescriptGrammar(editor: Atom.TextEditor): boolean {
3034
}
3135

3236
function isAllowedExtension(ext: string) {
33-
return [".ts", ".tst", ".tsx"].includes(ext)
37+
const tsExts = atom.config.get("atom-typescript.tsFileExtensions")
38+
if (atom.config.get("atom-typescript.allowJS")) {
39+
tsExts.push(...atom.config.get("atom-typescript.jsFileExtensions"))
40+
}
41+
return tsExts.includes(ext)
3442
}
3543

3644
export function getFilePathPosition(editor: Atom.TextEditor): FileLocationQuery | undefined {

lib/typings/atom-config.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,36 @@ declare module "atom" {
77
"atom-typescript.locale": string
88
"atom-typescript.preferBuiltinTooltips": boolean
99
"atom-typescript.preferBuiltinSigHelp": boolean
10+
"atom-typescript.preferBuiltinBusySignal": boolean
1011
"atom-typescript.buildStatusTimeout": number
1112
"atom-typescript.showSemanticView": boolean
1213
"atom-typescript.tooltipDelay": number
1314
"atom-typescript.ignoredDiagnosticCodes": string[]
1415
"atom-typescript.ignoreUnusedSuggestionDiagnostics": boolean
1516
"atom-typescript.suppressAllDiagnostics": boolean
17+
"atom-typescript.tsFileExtensions": string[]
18+
"atom-typescript.jsFileExtensions": string[]
19+
"atom-typescript.tsSyntaxScopes": string[]
20+
"atom-typescript.jsSyntaxScopes": string[]
21+
"atom-typescript.allowJS": boolean
1622
"atom-typescript": {
1723
unusedAsInfo: boolean
1824
autocompletionSuggestionPriority: number
1925
locale: string
2026
preferBuiltinTooltips: boolean
2127
preferBuiltinSigHelp: boolean
28+
preferBuiltinBusySignal: boolean
2229
buildStatusTimeout: number
2330
showSemanticView: boolean
2431
tooltipDelay: number
2532
ignoredDiagnosticCodes: string[]
2633
ignoreUnusedSuggestionDiagnostics: boolean
2734
suppressAllDiagnostics: boolean
35+
tsFileExtensions: string[]
36+
jsFileExtensions: string[]
37+
tsSyntaxScopes: string[]
38+
jsSyntaxScopes: string[]
39+
allowJS: boolean
2840
}
2941
}
3042
}

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,69 @@
111111
"type": "boolean",
112112
"default": "false",
113113
"order": 120
114+
},
115+
"tsFileExtensions": {
116+
"title": "TypeScript file extensions",
117+
"description": "Comma-separated list of TypeScript file extensions; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing",
118+
"type": "array",
119+
"items": {
120+
"type": "string"
121+
},
122+
"default": [
123+
".ts",
124+
".tst",
125+
".tsx"
126+
],
127+
"order": 130
128+
},
129+
"jsFileExtensions": {
130+
"title": "JavaScript file extensions",
131+
"description": "Comma-separated list of JavaScript file extensions; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing",
132+
"type": "array",
133+
"items": {
134+
"type": "string"
135+
},
136+
"default": [
137+
".js",
138+
".jst",
139+
".jsx"
140+
],
141+
"order": 140
142+
},
143+
"tsSyntaxScopes": {
144+
"title": "TypeScript syntax scopes",
145+
"description": "Comma-separated list of TypeScript syntax scopes; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing",
146+
"type": "array",
147+
"items": {
148+
"type": "string"
149+
},
150+
"default": [
151+
"source.ts",
152+
"source.tsx",
153+
"typescript"
154+
],
155+
"order": 150
156+
},
157+
"jsSyntaxScopes": {
158+
"title": "JavaScript syntax scopes",
159+
"description": "Comma-separated list of JavaScript syntax scopes; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing",
160+
"type": "array",
161+
"items": {
162+
"type": "string"
163+
},
164+
"default": [
165+
"source.js",
166+
"source.jsx",
167+
"javascript"
168+
],
169+
"order": 160
170+
},
171+
"allowJS": {
172+
"title": "Enable Atom-Typescript for JavaScript files (experimental)",
173+
"description": "Passes JS files to TypeScript server; Most likely need allowJS: true and checkJS: true in tsconfig",
174+
"type": "boolean",
175+
"default": false,
176+
"order": 170
114177
}
115178
},
116179
"deserializers": {

0 commit comments

Comments
 (0)