Skip to content

Commit 53b307a

Browse files
committed
Add webpack section tranlation
1 parent 9e94378 commit 53b307a

File tree

1 file changed

+54
-46
lines changed

1 file changed

+54
-46
lines changed

MIGRANDO.md

+54-46
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ Este Cheatsheet recopila consejos y utilidades de casos de estudios reales de eq
3232
> ⚠️ Este Cheatsheet es extremadamente nuevo y podría usar toda la ayuda que podamos obtener. Consejos sólidos, resultados, y contenido actualizado son bienvenidos.
3333
3434
## Prerrequisitos
35-
Lee la [Guía oficial de TypeScript para migrar desde JS](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html) y también deberías estar familiarizado con la [Guía de conversión de React](https://github.com/Microsoft/TypeScript-React-Conversion-Guide#typescript-react-conversion-guide).
35+
Leer la [Guía oficial de TypeScript para migrar desde JS](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html) y también deberías estar familiarizado con la [Guía de conversión de React](https://github.com/Microsoft/TypeScript-React-Conversion-Guide#typescript-react-conversion-guide).
3636

3737
## Enfoques de conversión general
3838

3939
- Nivel 0: No uses TypeScript, usa JSDoc
4040
- Mira nuestra [seccion de JSDoc](#JSDoc)
41-
- Nivel 1A: Majority JavaScript, increasingly strict TypeScript
41+
- Nivel 1A: JavaScript mayoritario, TypeScript cada vez más estricto
4242
- como recomienda la [guía oficial de TS](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html)
4343
- usa `allowJS` (Experiencias: [clayallsop][clayallsop], [pleo][pleo])
4444
- Nivel 1B: Renombrar todo a TypeScript desde el principio
@@ -48,34 +48,34 @@ Lee la [Guía oficial de TypeScript para migrar desde JS](https://www.typescript
4848
- usa [`dts-gen`](https://github.com/Microsoft/dts-gen) de Microsoft para generar archivos `.d.ts` para tus archivos sin tipo. [Esta respuesta de SO](https://stackoverflow.com/questions/12687779/how-do-you-produce-a-d-ts-typings-definition-file-from-an-existing-javascript) tiene mas información sobre el tema.
4949
- usa la palabra clasve `declare` para declaraciones de ambiente - mira la [declaración de fusión](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet#troubleshooting-handbook-bugs-in-official-typings) para parchear declaraciones de biblioteca en línea.
5050

51-
Misc tips/approaches successful companies have taken
51+
Varios consejos/enfoques que las empresas exitosas han tomado
5252

53-
- `@ts-ignore` on compiler errors for libraries with no typedefs
54-
- pick ESLint over TSLint (source: [ESLint](https://eslint.org/blog/2019/01/future-typescript-eslint) and [TS Roadmap](https://github.com/Microsoft/TypeScript/issues/29288)). [You can convert TSlint to ESlint with this tool](https://github.com/typescript-eslint/tslint-to-eslint-config).
55-
- New code must always be written in TypeScript. No exceptions. For existing code: If your task requires you to change JavaScript code, you need to rewrite it. (Source: [Hootsuite][hootsuite])
53+
- `@ts-ignore` en errores del compilador para librerias sin typedefs.
54+
- elije ESLint sobre TSLint (fuente: [ESLint](https://eslint.org/blog/2019/01/future-typescript-eslint) y [TS Roadmap](https://github.com/Microsoft/TypeScript/issues/29288)). [Puedes convertir TSlint a ESlint con esta herramienta](https://github.com/typescript-eslint/tslint-to-eslint-config).
55+
- El nuevo código siempre de escribirse en TypeScript. Sin excepciones. Para el código existente: Si tu tarea requiere cambiar el código JavaScript, debes volverlo a escribir. (Source: [Hootsuite][hootsuite])
5656

5757
<details>
5858
<summary>
5959
<b>
60-
Webpack tips
60+
Consejos para Webpack
6161
</b>
6262
</summary>
6363

64-
- webpack loader: `awesome-typescript-loader` vs `ts-loader`? (there is some disagreement in community about this - but read [awesome's point of view](https://github.com/s-panferov/awesome-typescript-loader#differences-between-ts-loader))
65-
- Webpack config:
64+
- webpack loader: `awesome-typescript-loader` vs `ts-loader`? (Hay un cierto desacuerdo en la comunidad sobre esto - pero lee [awesome's point of view](https://github.com/s-panferov/awesome-typescript-loader#differences-between-ts-loader))
65+
- configuración de Webpack:
6666

67-
```
67+
```js
6868
module.exports = {
6969

7070
resolve: {
7171
- extensions: ['.js', '.jsx']
7272
+ extensions: ['.ts', '.tsx', '.js', '.jsx']
7373
},
7474

75-
// Source maps support ('inline-source-map' also works)
75+
// Soporte para source maps ('inline-source-map' también funciona)
7676
devtool: 'source-map',
7777

78-
// Add the loader for .ts files.
78+
// Añadir el loader para archivos .ts.
7979
module: {
8080
loaders: [{
8181
- test: /\.jsx?$/,
@@ -93,38 +93,38 @@ module: {
9393
};
9494
```
9595

96-
Special note on `ts-loader` and 3rd party libraries: https://twitter.com/acemarke/status/1091150384184229888
96+
Nota especial sobre `ts-loader` y librerias de terceros: https://twitter.com/acemarke/status/1091150384184229888
9797

9898
</details>
9999

100100
## JSDoc
101101

102102
- https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript
103-
- webpack's codebase uses JSDoc with linting by TS https://twitter.com/TheLarkInn/status/984479953927327744 (some crazy hack: https://twitter.com/thelarkinn/status/996475530944823296)
103+
- El código base de webpack usa JSDoc con linting de TS https://twitter.com/TheLarkInn/status/984479953927327744 (un truco loco: https://twitter.com/thelarkinn/status/996475530944823296)
104104

105-
Problems to be aware of:
105+
Problemas a tener en cuenta:
106106

107-
- `object` is converted to `any` for some reason.
108-
- If you have an error in the jsdoc, you get no warning/error. TS just silently doesn't type annotate the function.
109-
- [casting can be verbose](https://twitter.com/bahmutov/status/1089229349637754880)
107+
- `object` se convierte a `any` por alguna razón.
108+
- Si tiene un error en el JSDoc, no recibes ningún warning/error. TS just silently doesn't type annotate the function.
109+
- [El casteo puede ser detallado](https://twitter.com/bahmutov/status/1089229349637754880)
110110

111-
(_thanks [Gil Tayar](https://twitter.com/giltayar/status/1089228919260221441) and [Gleb Bahmutov](https://twitter.com/bahmutov/status/1089229196247908353) for sharing above commentary_)
111+
(_gracias [Gil Tayar](https://twitter.com/giltayar/status/1089228919260221441) y [Gleb Bahmutov](https://twitter.com/bahmutov/status/1089229196247908353) por compartir el comentario anterior_)
112112

113-
## From JS
113+
## Desde JS
114114

115-
### Automated JS to TS Conversion
115+
### Conversión automatizada de JS a TS
116116

117-
- [TypeStat](https://github.com/JoshuaKGoldberg/TypeStat) ([used by Codecademy](https://mobile.twitter.com/JoshuaKGoldberg/status/1159090281314160640))
117+
- [TypeStat](https://github.com/JoshuaKGoldberg/TypeStat) ([usado por Codecademy](https://mobile.twitter.com/JoshuaKGoldberg/status/1159090281314160640))
118118
- [TypeWiz](https://github.com/urish/typewiz)
119119
- [js-to-ts-converter](https://github.com/gregjacobs/js-to-ts-converter)
120120

121-
### Manual JS to TS Conversion
121+
### Conversión manual de JS a TS
122122

123-
the "Just Renaming" strategy
123+
la estrategia de "Solo renombra"
124124

125125
- OSX/Linux: `find src -name "*.js" -exec sh -c 'mv"$0" "${0%.js}.tsx"' {} \;`
126126

127-
You can either load typescript files with webpack, or use the `tsc` compiler to compile your TS files to JS side by side. The basic `tsconfig.json` is:
127+
Puede cargar archivos de TypeScript con webpack o usar el compilador `tsc` para compilar sus archivos TS en JS uno al lado del otro. El `tsconfig.json` básico es:
128128

129129
```json
130130
{
@@ -134,7 +134,7 @@ You can either load typescript files with webpack, or use the `tsc` compiler to
134134
}
135135
```
136136

137-
Then you will want to enable it to check JS:
137+
Luego querrás habilitarlo para validar JS:
138138

139139
```json
140140
{
@@ -145,25 +145,26 @@ Then you will want to enable it to check JS:
145145
}
146146
```
147147

148-
If you have a large codebase and this throws too many errors at once, you can opt out problematic files with `//@ts-nocheck`, or instead turn off `checkJs` and add a `//@ts-check` directive at the top of each regular JS file.
148+
Si tiene una base de código grande y arroja demasiados errores a la vez, puedes optar por excluir archivos problemáticos con `//@ts-nocheck` o en su lugar desactivar `checkJs` y agregar una directiva `// @ ts-check` en la parte superior de cada archivo JS normal.
149149

150-
TypeScript should throw up some egregious errors here which should be easy to fix.
150+
TypeScript debería arrojar algunos errores atroces aquí que deberían ser fáciles de solucionar.
151151

152-
Once you are done, swallow the red pill by turning off implicit `any`'s:
152+
Una vez que haya terminado, trague la píldora roja apagando los `any` implícitos:
153153

154154
```js
155155
{
156156
"compilerOptions": {
157157
"allowJs": true,
158158
"checkJs": true,
159-
"noImplicitAny": true // or "strict": true
159+
"noImplicitAny": true // o "strict": true
160160
}
161161
}
162162
```
163163

164-
This will raise a bunch of type errors and you can start converting files to TS or (optionally) use [JSDoc annotations](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) in your JS.
164+
Esto generará un montón de errores de tipo y puedes comenzar a convertir archivos a TS u (opcionalmente) usar [anotaciones JSDoc](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) en tu JS.
165165

166-
A common practice here is using an ambient TODO type alias for `any` so you can keep track of what you need to come back to:
166+
167+
Una práctica común es usar alias de tipo TODO para `any`, para que puedas hacer un seguimiento de lo que necesita hacer luego.
167168

168169
```ts
169170
type TODO_TYPEME = any;
@@ -172,7 +173,7 @@ export function myFunc(foo: TODO_TYPEME, bar: TODO_TYPEME): number {
172173
}
173174
```
174175

175-
Gradually add [more `strict` mode flags](https://www.typescriptlang.org/docs/handbook/compiler-options.html) like `noImplicitThis`, `strictNullChecks`, and so on until you can eventually just run in full strict mode with no js files left:
176+
Gradualmente agrega [mas banderas de modo `strict`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) como `noImplicitThis`, `strictNullChecks`, y así sucesivamente hasta que finalmente pueda correr por completo en modo estricto sin que queden archivos js:
176177

177178
```js
178179
{
@@ -182,7 +183,7 @@ Gradually add [more `strict` mode flags](https://www.typescriptlang.org/docs/han
182183
}
183184
```
184185

185-
**More resources**
186+
**Más recursos**
186187

187188
- [Adopting TypeScript at Scale - AirBnB's conversion story and strategy](https://www.youtube.com/watch?v=P-J9Eg7hJwE)
188189
- [Migrating a `create-react-app`/`react-scripts` app to TypeScript](https://facebook.github.io/create-react-app/docs/adding-typescript) - don't use `react-scripts-ts`
@@ -192,29 +193,36 @@ Gradually add [more `strict` mode flags](https://www.typescriptlang.org/docs/han
192193
- [Storybook's migration (PR)](https://github.com/storybooks/storybook/issues/5030)
193194
- [How we migrated a 200K+ LOC project to TypeScript and survived to tell the story][coherentlabs] - Coherent Labs - using `grunt-ts`, jQuery and Kendo UI
194195

195-
Old content that is possibly out of date
196+
Contenido antiguo que posiblemente esté desactualizado
196197

197198
- [Incrementally Migrating JS to TS][clayallsop] (old)
198199
- [Microsoft's TypeScript React Conversion Guide][mstsreactconversionguide] (old)
199200

200-
## From Flow
201+
## Desde Flow
201202

202-
- Try flow2ts: `npx flow2ts` - doesn't work 100% but saves some time ([see this and other tips from @braposo](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/pull/79#issuecomment-458227322) at TravelRepublic)
203+
- Try flow2ts: `npx flow2ts` - doesn't work 100% but saves some time ([mira este y otros tips de @braposo](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/pull/79#issuecomment-458227322) at TravelRepublic)
203204
- [Incremental Migration to TypeScript on a Flowtype codebase][entria] at Entria
204-
- [MemSQL's Studio's migration](https://davidgom.es/porting-30k-lines-of-code-from-flow-to-typescript/) - blogpost with many useful tips
205+
- [MemSQL's Studio's migration](https://davidgom.es/porting-30k-lines-of-code-from-flow-to-typescript/) - blogpost con muchos tips útiles
205206
- Retail-UI's Codemod: https://github.com/skbkontur/retail-ui/tree/master/packages/react-ui-codemodes/flow-to-ts
206207
- Quick-n-dirty [Flow to TS Codemod](https://gist.github.com/skovhus/c57367ce6ecbc3f70bb7c80f25727a11)
207208
- [Ecobee's brief experience](https://mobile.twitter.com/alanhietala/status/1104450494754377728)
208209
- [Migrating a 50K SLOC Flow + React Native app to TypeScript](https://blog.usejournal.com/migrating-a-flow-react-native-app-to-typescript-c74c7bceae7d)
209210

210-
## Results
211+
## Resultados
212+
213+
- El número de despliegues de producción se duplicó para [Hootsuite][hootsuite]
214+
- Se encontraron globals accidentales para [Tiny][tiny]
215+
- Se encontraron llamadas a funciones incorrectas para [Tiny][tiny]
216+
- Se encontró un código de error poco utilizado que no se probó [Tiny][tiny]
217+
218+
## Estudios Académicos de Migración
219+
220+
- [To Type or Not to Type: Quantifying Detectable Bugs in JavaScript](http://earlbarr.com/publications/typestudy.pdf)
221+
222+
> Nuestro hallazgo central es que ambos sistemas de tipos estáticos encuentran un porcentaje importante de errores públicos: tanto Flow 0.30 como TypeScript 2.0 detectan con éxito el 15%.
211223
212-
- Number of production deploys doubled for [Hootsuite][hootsuite]
213-
- Found accidental globals for [Tiny][tiny]
214-
- Found incorrect function calls for [Tiny][tiny]
215-
- Found rarely used, buggy code that was untested for [Tiny][tiny]
224+
## Diversas historias de migración de compañías notables y fuentes abiertas
216225

217-
## Misc migration stories by notable companies and open source
218226

219227
- [Adopting TypeScript at Scale - AirBnB's conversion story and strategy](https://www.youtube.com/watch?v=P-J9Eg7hJwE)
220228
- [Lyft](https://eng.lyft.com/typescript-at-lyft-64f0702346ea)
@@ -224,7 +232,7 @@ Old content that is possibly out of date
224232
- [Priceline](https://medium.com/priceline-labs/trying-out-typescript-part-1-15a5267215b9)
225233
- Dropbox - [Talk at React Loop](https://www.youtube.com/watch?v=veXkJq0Z2Qk)
226234

227-
Open Source
235+
Código abierto
228236

229237
- [Jest's migration (PR)](https://github.com/facebook/jest/pull/7554#issuecomment-454358729)
230238
- [Expo's migration (issue)](https://github.com/expo/expo/issues/2164)
@@ -235,7 +243,7 @@ Open Source
235243
- [Next.js](https://nextjs.org/blog/next-9)
236244
- [Redux](https://github.com/reduxjs/redux/pull/3536)
237245

238-
## Links
246+
## Enlaces
239247

240248
[hootsuite]: https://medium.com/hootsuite-engineering/thoughts-on-migrating-to-typescript-5e1a04288202 "Thoughts on migrating to TypeScript"
241249
[clayallsop]: https://medium.com/@clayallsopp/incrementally-migrating-javascript-to-typescript-565020e49c88 "Incrementally Migrating JavaScript to TypeScript"

0 commit comments

Comments
 (0)