-
Notifications
You must be signed in to change notification settings - Fork 63
Convert 6 utils to TypeScript #1023
Changes from all commits
f29cff1
be13af5
bb215be
6a3b521
94f7dc4
9edcc69
4249d80
0b4555e
3ad59c2
16cd2c9
c40b471
5acea54
0b0bc48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ COPY pnpm-lock.yaml . | |
COPY .npmrc . | ||
|
||
# copy the nuxt configuration file | ||
COPY --from=builder /usr/app/nuxt.config.js . | ||
COPY --from=builder /usr/app/nuxt.config.ts . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😱 For some reason I didn't actually think we could use TypeScript for the nuxt config until Nuxt bridge/Nuxt 3 but this is great!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: if the previous stage is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question 🤔 The Nuxt config is used both to generate the Webpack config but also to configure some runtime properties for Nuxt, so it's used both for building and for runtime. Nuxt's runtime doesn't use TypeScript though, at least not in Nuxt 2, I don't think. If this is working I'm not entire sure why unless the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I understand now, I went to the docs, and Since the deployment target is not being specified in the config file, then the default value is
That means, at this point, if we want to keep using typescript (after building the application from the previous stage) we will require There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'd prefer if we kept it as TS for now until we move to Nuxt bridge. To use TS for this properly it looks like we'd have to bring in another module for it: https://typescript.nuxtjs.org/guide/runtime/ We can always add type-checking to the file even if it stays as JSDoc though; it just can't consume actual TS files (which means anything we use in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't use TS for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JS files can't import TS files without the JS files being compiled first. Because a Considering the e2e tests are passing (they run on the Also don't know why it's working though (which scares me a little bit 😅) |
||
|
||
# copy distribution directory with the static content | ||
COPY --from=builder /usr/app/.nuxt /usr/app/.nuxt | ||
|
@@ -106,4 +106,3 @@ EXPOSE 8443 | |
|
||
# run the application in static mode | ||
ENTRYPOINT ["pnpm", "run", "start"] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
</template> | ||
|
||
<script> | ||
import { isTest } from '~/utils/node-env' | ||
|
||
/** | ||
* Displays the given icon in a 24px × 24px square. | ||
*/ | ||
|
@@ -33,7 +35,7 @@ export default { | |
/** | ||
* In `jest` our icons get transformed to Vue components | ||
*/ | ||
type: process.env.NODE_ENV === 'test' ? Object : String, | ||
type: isTest ? Object : String, | ||
Comment on lines
-36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to check that dead code elimination still works when you don't inline the NODE_ENV check. I don't think we have environment based dead code currently but it would be good to add that. We might end up having to revert these checks back to the inline but I'm not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make a new issue for this, it seems that this should work because it'll evaluate to if (false) {
// ...
} in the compiled JS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #1030. |
||
required: true, | ||
}, | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
/** | ||
* @typedef {{ code: string, wpLocale?: string, file?: string, iso?: string, name: string, dir?: string, translated?: number }} i18nLocaleProps | ||
*/ | ||
export interface I18nLocaleProps { | ||
code: string | ||
name: string | ||
wpLocale?: string | ||
file?: string | ||
iso?: string | ||
dir?: string | ||
translated?: number | ||
} |
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.
I still think we might want to use https://www.npmjs.com/package/eslint-plugin-jsdoc instead of a TSDoc one. We have no real idea of how long Vue files will be excluded from TS and it'd be nice to have consistency across the stack with our JSDoc comments.
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.
Let's address the JSDoc changes in #1029.