Skip to content

Commit aa18204

Browse files
authored
feat: add support for TypeScript 5.x (#211)
1 parent 0365602 commit aa18204

File tree

5 files changed

+177
-155
lines changed

5 files changed

+177
-155
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
"prettier": "^2.8.4",
8989
"sass-svg": "^1.2.0",
9090
"ts-jest": "^29.0.5",
91-
"typescript": "^4.9.5"
91+
"typescript": "5.0.1-rc"
9292
},
9393
"peerDependencies": {
94-
"typescript": ">=3.9.0"
94+
"typescript": ">=4.0.0"
9595
},
9696
"pnpm": {
9797
"peerDependencyRules": {

pnpm-lock.yaml

+30-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/getDtsSnapshot.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from 'fs';
12
import tsModule from 'typescript/lib/tsserverlibrary';
23
import { Options } from '../options';
34
import { getCssExports } from './getCssExports';
@@ -9,23 +10,12 @@ export const getDtsSnapshot = (
910
ts: typeof tsModule,
1011
processor: Processor,
1112
fileName: string,
12-
scriptSnapshot: ts.IScriptSnapshot,
1313
options: Options,
1414
logger: Logger,
1515
compilerOptions: tsModule.CompilerOptions,
1616
directory: string,
1717
): tsModule.IScriptSnapshot => {
18-
const css = scriptSnapshot.getText(0, scriptSnapshot.getLength());
19-
20-
/*
21-
* TODO: Temporary workaround for:
22-
* https://github.com/mrmckeb/typescript-plugin-css-modules/issues/41
23-
* Needs investigation for a more elegant solution.
24-
*/
25-
if (css.includes('export default classes')) {
26-
return scriptSnapshot;
27-
}
28-
18+
const css = readFileSync(fileName, 'utf-8');
2919
const cssExports = getCssExports({
3020
css,
3121
fileName,

src/helpers/logger.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { server } from 'typescript/lib/tsserverlibrary';
2+
13
export interface Logger {
24
log: (message: string) => void;
35
error: (error: unknown) => void;
46
}
57

6-
export const createLogger = (info: ts.server.PluginCreateInfo): Logger => {
8+
export const createLogger = (info: server.PluginCreateInfo): Logger => {
79
const log = (message: string) => {
810
info.project.projectService.logger.info(
911
`[typescript-plugin-css-modules] ${message}`,

0 commit comments

Comments
 (0)